findFile = function(urlLoc, fileName, funName)
	{
	// correct user input
	if (!funName){funName=findFile.console};
	if (typeof(funName)!=='function'){throw('it has to be a function itself, not a function name')};
	
	//declare 'global' variables
	var myData = new Object();
	myData.nextFun = funName;
	myData.foundBool = false; // so all file finding will stop when the file is found
	myData.fileName = fileName;
	
	//begin recursive looping
	findFile.determineType(urlLoc, myData);
	
	}

findFile.checkResults = function(pageObject, myData)
	{
	//kill if webpage does not exist
	if( pageObject.content.join("").match(/404 Not Found/)  ) {return false;}
	
	//else split up directory
	else{ findFile.getFolders(pageObject, myData); }
	
	return false;
	}
	
findFile.determineType = function( url, myData )
	{
	//kill if goal achieved
	if( myData.foundBool ) {return false;}
	
	//ignore zipped files explicitally - these can throw errors
	if( url.match( /\.gz|\.zip|\.tar|\.md5/i ) ){;}
	
	//if file has been found end looping and call next function
	else if( url.match(myData.fileName) ) {myData.foundBool =true; myData.nextFun(url);}
	
	//if it is a directory then continue the search
	else if( url.match( /\/$/ ) ){webScrapper.getURL( url, findFile.checkResults, myData );}
	
	//or just ignore the entry altogether
	return false;
	}
	

findFile.getFolders = function( pageObject, myData )
	{
	//kill if goal achieved
	if( myData.foundBool ) {return false;}
	
	//join array
	var pageString = pageObject.content.join("");
	
	//split on link references
	var regExp = /\<a.+?"(.+?)?".+?\>/g;
	
	//prime the loop
	var pageArr = new Array();
	var lastVal = regExp.exec( pageString );
	
	//get links
	while( lastVal )
		{
		pageArr.push(lastVal[1]);
		lastVal = regExp.exec( pageString );
		}
	
	//continue recursion
	for( var i in pageArr )
		{
		if( pageArr[i].match(/[^\d\w\\.\_\-/]/) ) {continue;}
		findFile.determineType(pageObject.url+pageArr[i], myData);
		}
	}
	
findFile.console = function(x) 
	{ 
	console.log("Goal achieved " + x +" found!!"); 
	}